﻿@*YoursLC有源低代码 Create:admin 2023-07-04 14:31:12 列表-此文件放置于Views/ApprovalOfEmploymentApplication /中*@

@using Think9.Models;
@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiList.cshtml"; }

@*入职申请*@
<input style="display:none" id="_isDebug" value="debug">@*debug为调试；release为发布*@
<input style="display:none" id="_fwid" value="fw_ApprovalOfEmploymentApplication">
@*弹出选择时页面间传递数据*@
<input style="display:none" id="pu_value">@*弹出选择时使用-选择的值*@
<input style="display:none" id="pu_tbid">@*弹出选择时使用-表id*@
<input style="display:none" id="pu_indexid">@*弹出选择时使用-指标编码*@
<input style="display:none" id="pu_rowid">@*弹出选择时使用-子表弹出，对应tableid 哪一行*@
<input style="display:none" id="pu_column">@*弹出选择时使用-子表弹出，第几列*@
<fieldset class="table-fieldset" id="searchfield" style="display:none">
    <legend style="color:darkgrey">快速查询 -<span id="sp_searchmode"></span> </legend>
    <div style="margin: 5px 5px 5px 5px">
        <form class="layui-form layui-form-pane" action=""  id="_formid">
			<div class="layui-row layui-col-space10">
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">员工姓名</label>
					<div class="layui-input-block">
						<input type='text' name="inYGXM" id="inYGXM" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<select id="inXB" name="inXB">
							<option value="">==请选择==</option>
								@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inXB"))
								{
									 <option value="@item.Value">@item.Text</option>
								}
						</select>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">手机号码</label>
					<div class="layui-input-block">
						<input type='text' name="inSJHM" id="inSJHM" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">入职日期</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 90px; ">
							<input name="inRZRQ" id="inRZRQ" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 90px; ">
							<input name="inRZRQ_Exa" id="inRZRQ_Exa" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">入职部门</label>
					<div class="layui-input-block">
						<select id="inRZBM" name="inRZBM">
							<option value="">==请选择==</option>
								@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inRZBM"))
								{
									 <option value="@item.Value">@item.Text</option>
								}
						</select>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">担任职务</label>
					<div class="layui-input-block">
						<select id="inDRZW" name="inDRZW">
							<option value="">==请选择==</option>
								@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inDRZW"))
								{
									 <option value="@item.Value">@item.Text</option>
								}
						</select>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">备注</label>
					<div class="layui-input-block">
						<input type='text' name="inNote09" id="inNote09" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">审批意见</label>
					<div class="layui-input-block">
						<input type='text' name="inApprovalOpinions" id="inApprovalOpinions" autocomplete='off' class='layui-input'>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<label class="layui-form-label">审批时间</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 90px; ">
							<input name="inApprovalTime" id="inApprovalTime" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 90px; ">
							<input name="inApprovalTime_Exa" id="inApprovalTime_Exa" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<button type='button' class='layui-btn' id='search' lay-submit lay-filter='search' lay-tips='查询'><i class='layui-icon layui-icon-search'></i></button> <button type='button' class='layui-btn layui-btn-warm' id='exportData' lay-submit lay-filter='exportData' lay-tips='查询并导出Excel'><i class='fa fa-file-excel-o'></i></button> <button type='reset' class='layui-btn layui-btn-primary' lay-tips='清空'><i class='layui-icon layui-icon-refresh'></i></button>
				</div>
			 </div>
        </form>
    </div>
</fieldset>

<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
<script>
    layui.config({
        base: '/self_js/' /*自定义的js文件 wwwroot/self_js文件夹中*/
    });
    layui.use(["table", "form", "exLayer", "exUtils", "miniPage", "ApprovalOfEmploymentApplication"], function () {
        let table = layui.table;
        let form = layui.form;
        let miniPage = layui.miniPage;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let myJS = layui.ApprovalOfEmploymentApplication;

        let $ = layui.$;
        var openWH = miniPage.getOpenWidthHeight();
        form.render();

        $("#sp_searchmode").text("@ViewBag.SearchMode");

        let ThisTable = table.render({
            elem: "#tableId",
            url: "/_TB/GetPageList" + "?fwid=" + $("#_fwid").val(),
            limits: [10, 50, 100],
            limit: 10,
            method:"POST",
            page: true,
            defaultToolbar: layui.device().mobile ? [{ title: '搜索', layEvent: 'searchShow', icon: 'layui-bg-blue layui-icon-search' }, { title: '显示所有数据', layEvent: 'refresh', icon: 'layui-bg-gray layui-icon-refresh' }] : [{ title: '搜索', layEvent: 'searchShow', icon: 'layui-bg-blue layui-icon-search' }, { title: '显示所有数据', layEvent: 'refresh', icon: 'layui-bg-gray layui-icon-refresh' }, 'filter'],
            toolbar: "#toolbarTpl",
            cols: [[
                { type: "checkbox", fixed: 'left' },
                { type: "numbers", title: "NO.", fixed: 'left' },
                { title: "", width: 45, title: "<i class='fa fa-unlock-alt'></i>" , templet: "#is_lock" },
				{ field: "inYGXM", title: "员工姓名", width: 150, sort: true   },
				{ field: "inXB", title: "性别", width: 150, sort: true   },
				{ field: "inSJHM", title: "手机号码", width: 150, sort: true   },
				{ title: "入职日期", width: 70 , sort: true , templet: '<span>{{showDate(d.inRZRQ)}}<span>'  },
				{ field: "inRZBM", title: "入职部门", width: 150, sort: true   },
				{ field: "inDRZW", title: "担任职务", width: 150, sort: true   },
				{ field: "inNote09", title: "备注", width: 150, sort: true   },
				{ field: "inApprovalOpinions", title: "审批意见", width: 150, sort: true   },
                { field: "currentPrcsName", title: "流程步骤", fixed: layui.device().mobile ? null : 'right', templet: "#prcslist", width: 100, sort: true },
                { title: "操作", width: 230, align: "center", fixed: layui.device().mobile ? null : 'right', templet: "#operation_Tpl" }
            ]],
            done: function (res, curr, count) {
                myJS.setListButDisable("@ViewBag.DisableBut");//控制list页面按钮状态
                if (count == -1) {
                    //layer.msg(res.msg, { icon: 5, time: 20000, btn: ['关闭'] });//显示错误
                }
            }
        });

         //查询
        form.on("submit(search)", function (data) {
            $("#searchfield").hide();
            ThisTable.reload({
                where: { model: data.field, json: JSON.stringify(data.field, null, 4)},
                url: "/_TB/GetPageList" + "?fwid=" + $("#_fwid").val(),
                page: { curr: 1 }
            });
            return false;
        });

        //导出
        form.on("submit(exportData)", function (data) {
            exUtils.ajax("/_TB/ExportData", "post", { json: JSON.stringify(data.field, null, 4), fwid: $("#_fwid").val() }, true).done(function (response) {
                layer.open({
                    title: response.message
                    , type: 1
                    , area: ['250', '100px']
                    , content: response.extra
                });
            }).fail(function (error) {
                console.log(error);
            });
        });



        table.on("toolbar(tableFilter)", function (obj) {
            switch (obj.event) {
                case "add":
                    add();
                    break;
                 case "importExcel":
                    exLayer.open("数据导入", "/SysTable/ImportData/ImportDataFromExcel?tbid=tb_ApprovalOfEmploymentApplication", openWH[0] + 'px', openWH[1] + 'px', openWH[2] + 'px', openWH[3] + 'px', null, null);
                    break;
                case "searchShow":
                    myJS.searchShow();
                    break;
                case "refresh":
                    $("#searchfield").hide();
                    ThisTable.reload({
                        url: "/_TB/GetPageList?isAll=all" + "&fwid=" + $("#_fwid").val(),
                        page: { curr: 1 }
                    });
                    break;
                case "mergeExport":
                    mergeExport();
                    break;
                case "batchDel":
                    batchDel();
                    break;
            }
        });

        table.on("tool(tableFilter)", function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case "detail":
                    //select弹出页面选择，pdf直接打开文件，html打开网页
                    showDetailCom($('#_fwid').val(), data.ListId, 'select');//在global.js中定义
                    break;
                case "record":
                    record(data.ListId);
                    break;
                case "edit":
                    edit(data.ListId);
                    break;
                case "prcslist":
                    exLayer.open('记录查看', '/SysFlow/FlowRunList/RecordList?listid=' + data.ListId + "&fwid=" + $("#_fwid").val(), openWH[0] + 'px', openWH[1] + 'px', openWH[2] + 'px', openWH[3] + 'px', null, null);
                    break;
                case "del":
                    del(data.ListId);
                    break;
            }
        });

        function add() {
            exUtils.ajax("/_TB/BeforeAdd", "post", { type: 'add', listid: '0', fwid: $("#_fwid").val() }, true).done(function (response) {
                exLayer.open("入职申请 - 新增数据", "/_TB/Form?listid=" + response.extra + "&pid=" + response.extra2 + "&type=add" + "&fwid=" + $("#_fwid").val(), openWH[0] + 'px', openWH[1] + 'px', openWH[2] + 'px', openWH[3] + 'px', null, null);
            }).fail(function (error) {
                console.log(error);
            });
        }

        function edit(id) {
            exUtils.ajax("/_TB/BeforeEdit", "post", { type: 'edit', listid: id, fwid: $("#_fwid").val()}, true).done(function (response) {
                exLayer.open("入职申请 - 编辑数据", "/_TB/Form?listid=" + id + "&pid=" + response.extra2 + "&type=edit" + "&fwid=" + $("#_fwid").val(), openWH[0] + 'px', openWH[1] + 'px', openWH[2] + 'px', openWH[3] + 'px', null, null);
            }).fail(function (error) {
                console.log(error);
            });
        }

        function record(id) {
            exLayer.open('记录查看', '/SysFlow/FlowRunList/RecordList?listid=' + id + "&fwid=" + $("#_fwid").val(), openWH[0] + 'px', openWH[1] + 'px', openWH[2] + 'px', openWH[3] + 'px', null, null);
        }

        function del(id) {
            exLayer.confirm("确定要删除吗？", function () {
                exUtils.ajax("/_TB/Delete", "get", { listid: id, fwid: $("#_fwid").val() }, true).done(function (response) {
                    exUtils.tableSuccessMsg(response.message);
                    $(".layui-laypage-btn")[0].click();
                }).fail(function (error) {
                    console.log(error);
                });
            })
        }

        //弹出页面关闭后为控件赋值 无弹出页面可删除
        $("#pu_value").click(function () {
            myJS.getValueFromPopUp();//弹出页面关闭后，将选择的Value赋值给触发弹出页面的input，在自定义js中定义
        });

        //处理查询参数
        function jsonToUrlParam(json) {
            return Object.keys(json).map(key => key + '=' + json[key]).join('&');
        }

        function batchDel() {
            var idsStr = "";
            var checkStatus = table.checkStatus("tableId");
            var rows = checkStatus.data.length;
            if (rows > 0) {
                for (var i = 0; i < checkStatus.data.length; i++) {
                    idsStr += checkStatus.data[i].ListId + ",";
                }
                exLayer.confirm("确定要删除吗？", function (index) {
                    layer.close(index);
                    if (idsStr) {
                        exUtils.ajax("/_TB/BatchDel", "post", { idsStr: idsStr, fwid: $("#_fwid").val() }, true).done(function (response) {
                            exUtils.tableSuccessMsg(response.message);
                            $(".layui-laypage-btn")[0].click();
                        }).fail(function (error) {
                            console.log(error);
                        });
                    }
                });
            }
            else {
                layer.msg("未选择有效数据");
            }
        }

       function mergeExport() {
            var idsStr = "";
            var checkStatus = table.checkStatus("tableId");
            var rows = checkStatus.data.length;
            if (rows > 0) {
                for (var i = 0; i < checkStatus.data.length; i++) {
                    idsStr += checkStatus.data[i].ListId + ",";
                }
                if (idsStr) {
                    exUtils.ajax("/_TB/MergeExport", "post", { idsStr: idsStr, fwid: $("#_fwid").val() }, true).done(function (response) {
                        layer.open({
                            title: response.message
                            , type: 1
                            , area: ['250', '100px']
                            , content: response.extra
                        });
                    }).fail(function (error) {
                        console.log(error);
                    });
                }
            }
            else {
                layer.msg("未选择有效数据");
            }
        }
    });
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
  <div class="layui-btn-container"> 
	<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="batchDel" id="batchDel"><i class="fa fa-trash-o"></i>批量删除</button>
	<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="mergeExport" id="mergeExport"><i class="fa fa-file-pdf-o"></i>合并导出</button>
	<button class="layui-btn layui-btn-sm" lay-event="importExcel" id="importExcel"><i class="fa fa-file-excel-o"></i>数据导入</button>
    <button type="button" class="layui-btn layui-btn-warm layui-btn-sm" lay-event="add" id="add"><i class="fa fa-plus"></i>新增数据</button>
   </div>
</script>
<!-- 行工具栏模板 锁定 -->
<script type='text/html' id='is_lock'>
    {{#  if(d.isLock == '0'){ }}
    <i class='fa fa-unlock'></i>
    {{#  }else{ }}
    <i class='fa fa-lock'></i>
    {{#  } }}
</script>
<!-- 行工具栏模板 流程步骤 -->
<script type='text/html' id='prcslist'>
    {{#  if(d.DisableButStr == 'all' || d.DisableButStr.indexOf("[listprcs]") > -1){ }}
    <a class='layui-btn-rimary layui-btn-sm' href='javascript:;' id='listprcs'>{{d.currentPrcsName}}</a>
    {{#  }else{ }}
    {{#  if(d.runFlag == '1'){ }}
    <a class='layui-btn-rimary layui-btn-sm' style='color: #FE7300;' href='javascript:;' lay-event='prcslist' id='listprcs'>{{d.currentPrcsName}}</a>
    {{#  }else{ }}
    <a class='layui-btn-rimary layui-btn-sm' style='color: blue;' href='javascript:;' lay-event='prcslist' id='listprcs'>{{d.currentPrcsName}}</a>
    {{#  } }}
    {{#  } }}
</script>
<!-- 行工具栏模板 操作按钮 DisableButStr禁用按钮字符，格式[butid1][butid2]，用于按钮权限控制，录入表管理/页面按钮可设置-->
<script type="text/html" id="operation_Tpl">
	{{#  if(d.DisableButStr == 'all' || d.DisableButStr.indexOf("[detail]") > -1){ }}
	<a href='javascript:;' class="layui-btn layui-btn-disabled layui-btn-xs" id="detail">详细</a>
	{{#  }else{ }}
	<a href='javascript:;' class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail" id="detail">详细</a>
	{{#  } }}
	
	{{#  if(d.DisableButStr == 'all' || d.DisableButStr.indexOf("[record]") > -1){ }}
	<a href='javascript:;' class="layui-btn layui-btn-disabled layui-btn-xs" id="record">记录</a>
	{{#  }else{ }}
	<a href='javascript:;' class="layui-btn layui-btn-normal layui-btn-xs" lay-event="record" id="record">记录</a>
	{{#  } }}
    {{#  if(d.DisableButStr == 'all' ||  d.DisableButStr.indexOf("[edit]") > -1){ }}
    <a href='javascript:;' class="layui-btn layui-btn-disabled layui-btn-xs" id="edit">编辑</a>
    {{#  }else{ }}
    <a href='javascript:;' class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit" id="edit">编辑</a>
    {{#  } }}

    {{#  if(d.DisableButStr == 'all' ||  d.DisableButStr.indexOf("[del]") > -1){ }}
    <a href='javascript:;' class="layui-btn layui-btn-disabled layui-btn-xs" id="del">删除</a>
    {{#  }else{ }}
    <a href='javascript:;' class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="del">删除</a>
    {{#  } }}
</script>

<!-- 图片显示 -->
<script>
    function PopUpImg(id) {
        showImg(id);//在global.js中定义
    }
</script>